<!--
 * @Description: 
 * @Autor: 商晓彬
 * @Date: 2021-08-20 13:57:03
 * @LastEditors: 商晓彬
 * @LastEditTime: 2022-02-16 14:17:25
-->

<div class="warehousing">
    <div class="m-subheader">
        <div class="row align-items-center">
            <div class="mr-auto col-auto">
                <h3 class="m-subheader__title m-subheader__title--separator">
                    <span>退库记录</span>
                </h3>
            </div>
        </div>
    </div>
    <div class="m-content">
        <div class="m-portlet m-portlet--mobile">
            <div class="m-portlet__body">
                <div class="p-formgroup-inline" style="margin-top: 10px;">
                    <span class="p-field">
                        <span class="input-lable">退库单号：</span>
                        <input pInputText style=" width:120px;height: 35px;"
                                name="exNo" type="text" [(ngModel)]="exNo" />
                    </span>
                    <span class="p-field ml">
                        <span class="input-lable">仓库名称：</span>
                        <p-dropdown filter="true" name="stroeName" [options]="stroeNameOptions" placeholder="请选择仓库名称"
                            [(ngModel)]="stroeName" emptyFilterMessage="暂无数据">
                            <ng-template let-item pTemplate="selectedItem">
                                <span *ngIf="stroeName != undefind "
                                    style="vertical-align:middle; margin-left: .5em;width: 117px;">{{item.label}}</span>
                                <span *ngIf="stroeName == undefind "
                                    style="vertical-align:middle; margin-left: .5em;width: 117px;"> </span>
                            </ng-template>
                            <ng-template let-model pTemplate="item">
                                <div class="ui-helper-clearfix" style="position: relative;height: 25px;">
                                    <div style="font-size:14px;float:right;margin-top:4px;width: 117px;">{{model.label}}
                                    </div>
                                </div>
                            </ng-template>
                        </p-dropdown>
                    </span>
                    <span class="p-field ml">
                        <span class="input-lable">装配任务号：</span>
                        <input pInputText style=" width:120px;height: 35px;"
                        name="assemblyTaskNumber" type="text" [(ngModel)]="assemblyTaskNumber" />
                    </span>
                    <span class="p-field ml">
                        <span class="input-lable">合格证号：</span>
                        <input pInputText style=" width:120px;height: 35px;"
                                name="qualifiedTaskNumber" type="text" [(ngModel)]="qualifiedTaskNumber" />
                    </span>
                    <span class="p-field ml">
                        <span class="input-lable">放行单号：</span>
                        <input pInputText style=" width:120px;height: 35px;"
                                name="releaseOrder" type="text" [(ngModel)]="releaseOrder" />
                    </span>
                    <span class="p-field ml">
                        <span class="input-lable">型号：</span>
                        <p-dropdown filter="true" name="model" [options]="modelOptions"
                            placeholder="请选择型号" [(ngModel)]="model" emptyFilterMessage="暂无数据" (onChange)="onChange($event)">
                            <ng-template let-item pTemplate="selectedItem">
                                <span *ngIf="model != undefind "
                                    style="vertical-align:middle; margin-left: .5em;width: 117px;">{{item.label}}</span>
                                <span *ngIf="model == undefind "
                                    style="vertical-align:middle; margin-left: .5em;width: 117px;"> </span>
                            </ng-template>
                            <ng-template let-model pTemplate="item">
                                <div class="ui-helper-clearfix" style="position: relative;height: 25px;">
                                    <div style="font-size:14px;float:right;margin-top:4px;width: 117px;">{{model.label}}
                                    </div>
                                </div>
                            </ng-template>
                        </p-dropdown>
                    </span>
                    <span class="p-field ml">
                        <span class="input-lable">发次：</span>
                        <p-dropdown filter="true" name="senTime" [options]="sendTimeOptions"
                            placeholder="请选择发次" [(ngModel)]="sendTime" emptyFilterMessage="暂无数据">
                            <ng-template let-item pTemplate="selectedItem">
                                <span *ngIf="senTime != undefind "
                                    style="vertical-align:middle; margin-left: .5em;width: 117px;">{{item.label}}</span>
                                <span *ngIf="senTime == undefind "
                                    style="vertical-align:middle; margin-left: .5em;width: 117px;"> </span>
                            </ng-template>
                            <ng-template let-model pTemplate="item">
                                <div class="ui-helper-clearfix" style="position: relative;height: 25px;">
                                    <div style="font-size:14px;float:right;margin-top:4px;width: 117px;">{{model.label}}
                                    </div>
                                </div>
                            </ng-template>
                        </p-dropdown>
                    </span>
                    <p-button label="查询" (onClick)="getTableList()" class="ml"></p-button>
                    <p-button label="重置" (onClick)="reset()" class="ml"></p-button>
                </div>
                <div class="p-formgroup-inline" style="margin-top: 10px;">
                    <p-button *ngIf="'Pages.StockRecord.ConsumablesRecord' | permission" label="耗材记录" (onClick)="openUrl()" class="ml"></p-button>
                </div>
                <div class="row align-items-center" style="margin-top: 25px;">
                    <div class="primeng-datatable-container">
                        <p-table #dataTable [value]="primengTableHelper.records" (onLazyLoad)="getTableList($event)"
                            rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
                            [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
                            [resizableColumns]="primengTableHelper.resizableColumns">
                            <ng-template pTemplate="header">
                                <tr>
                                    <th style="width: 150px">操作</th>
                                    <th style="width: 50px">序号</th>
                                    <th style="width: 150px">退库单号</th>
                                    <th style="width: 150px">出库单号</th>
                                    <th style="width: 150px">仓库名称</th>
                                    <th style="width: 150px">装配任务号</th>
                                    <th style="width: 150px">型号</th>
                                    <th style="width: 150px">发次</th>
                                    <th style="width: 150px">退库类型</th>
                                    <th style="width: 350px">退库原因</th>
                                    <th style="width: 150px">退库人</th>
                                    <th style="width: 150px">退库时间</th>
                                </tr>
                            </ng-template>
                            <ng-template pTemplate="body" let-record="$implicit" let-rowIndex="rowIndex">
                                <tr>
                                    <td style="width: 150px">
                                        <div class="btn-group dropdown" dropdown container="body">
                                            <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                                                <i class="fa fa-cog"></i><span class="caret"></span> 操作
                                            </button>
                                            <ul class="dropdown-menu" *dropdownMenu>
                                                <li>
                                                    <a *ngIf="'Pages.StockRecord.Resume' | permission" href="javascript:;" (click)="lookResume(record)">履历</a>
                                                </li>
                                                <li>
                                                    <a *ngIf="'Pages.StockRecord.See' | permission" href="javascript:;" (click)="watch(record)">查看</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                    <td style="width: 50px">{{rowIndex+1}}</td>
                                    <td style="width: 150px">{{record.cancellingStocksNo}}</td>
                                    <td style="width: 150px">{{record.deliveryNo}}</td>
                                    <td style="width: 150px">{{record.stroeName}}</td>
                                    <td style="width: 150px">{{record.assemblyTaskNumber}}</td>
                                    <td style="width: 150px">{{record.model}}</td>
                                    <td style="width: 150px">{{record.lotNo}}</td>
                                    <td style="width: 150px">{{record.cancellingDesc}}</td>
                                    <td style="width: 350px">{{record.cancellingReason}}</td>
                                    <td style="width: 150px">{{record.cancellingUser}}</td>
                                    <td style="width: 150px">{{record.cancellingTime | momentFormat:'YYYY-MM-DD
                                        HH:mm:ss'}}</td>
                                </tr>
                            </ng-template>
                        </p-table>
                        <div class="primeng-paging-container">
                            <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                                (onPageChange)="getTableList($event)"
                                [totalRecords]="primengTableHelper.totalRecordsCount"
                                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">
                            </p-paginator>
                            <span class="total-records-count">
                                {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
                            </span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- 履历 -->
    <app-add-show-resume #AddShowResumeComponent [parentInfo]="rowdata"></app-add-show-resume>
    <!-- 配套退库 -->
    <app-return-warehouse [checktype]="checktype" #ReturnWarehouseComponent [warehouseInfo]="rowdata"></app-return-warehouse>
        <!-- 新增出库 -->
    <app-add-ex [checktype]="checktype" #AddExComponent [warehouseInfo]="rowdata"></app-add-ex>
</div>